package com.banach.prema.im.callback;

import com.alibaba.fastjson.JSON;
import com.banach.prema.im.annotation.CallbackCommand;
import com.banach.prema.im.annotation.Callback;
import com.banach.prema.repository.C2CMsgRepository;
import com.banach.prema.repository.dataobject.C2CMsgDO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
/**
 * 单发消息
 * @author ajun
 *
 */
@Service
@Callback
public class C2cCallBackService {
	private final static CallBackResponse SUCCESS_RESPONSE = CallBackResponse.createSuccessResponse();

	@Resource
	private C2CMsgRepository c2cMsgRepository;

	
	/**
	 *发消息之后回调
	 * @return
	 */
	@CallbackCommand("C2C.CallbackAfterSendMsg")
	public CallBackResponse afterSendMsg(String text){
		C2CMsgDO msg = JSON.parseObject(text, C2CMsgDO.class);
		c2cMsgRepository.save(msg);
		return SUCCESS_RESPONSE;
	}

}
